<template>
    <el-row>
        <el-row>
            <el-col class="title box box-pack-between">
                <el-select v-model="selectVal" placeholder="请选择" @change="handleSelect" class="text">
                    <el-option label="全部" value=""></el-option>
                    <el-option label="老师" value="6"></el-option>
                    <el-option label="学生" value="9"></el-option>
                </el-select>
                <div class="btn">
                    <el-input class="reset-input" placeholder="搜索" v-model="searchText">
                        <i slot="suffix" class="el-input__icon el-icon-search cp" @click="getData()"></i>
                    </el-input>
                </div>
            </el-col>
        </el-row>

        <el-row class="mt20">
            <el-col>
                <el-table :data="page.list" stripe style="width: 625px"
                    :header-cell-style="{background:'#F0F1F8', color:'#2F3142'}" border>
                    <el-table-column type="index" label="序号" width="80" align="center"></el-table-column>
                    <el-table-column prop="roleName" label="角色" width="120" align="center"></el-table-column>
                    <el-table-column prop="name" label="姓名" align="center"></el-table-column>
                    <el-table-column prop="userCode" label="登录账号" align="center"></el-table-column>
                </el-table>
            </el-col>
        </el-row>
    </el-row>
</template>

<script>
    export default {
        data() {
            return {
                page: {
                    total: 0,
                    pageSize: 10,
                    pageNum: 1,
                    list: []
                },
                tkzt: false,
                selectVal: '',
                searchText: '',
                title: '添加',
                schoolid:this.$store.getters.getLoginInfo.user.schoolId,
            };
        },
        mounted() {
            this.getData();
        },
        methods: {
            tableRowClassName({
                row,
                rowIndex
            }) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            },
            getData() {
                let params = {
                    schoolid: this.schoolid,
                    searchtext: this.searchText,
                    roleid: this.selectVal,
                    pageNum:this.page.pageNum,
                    pageSize:this.page.pageSize
                };
                this.$api.Admin.getAccData(params).then(res => {
                    console.log(res);
                    if (res.code == '0') {
                        this.page = res.list;
                    } else {
                        this.$message.error('请求失败！');
                    }
                })
            },
            handleSelect() {
                this.getData();
            },
            clickAdd() {

            }
        }
    }
</script>

<style>
    .el-table .warning-row {
        background: oldlace;
    }

    .el-table .success-row {
        background: #f0f9eb;
    }
</style>
